const timeReg = /\[(\d{2}):(\d{2})\.(\d{2,3})\]/ 

export function parseLyric(lrcString) {
    const lyricInfos = []
    const lyricLine = lrcString.split("\n")
    for (let i of lyricLine) {
        const timeInfo = timeReg.exec(i)
        if (!timeInfo) continue
        const m = timeInfo[1] * 60 * 1000
        const s = timeInfo[2] * 1000
        const ms = timeInfo[3].length === 2 ? timeInfo[3] * 10 : timeInfo[3] * 1
        const time = m + s + ms
        const text = i.replace(timeReg,"") 
        let lyricInfo = {
            time,
            text
        }
        lyricInfos.push(lyricInfo)
    }
    
    return lyricInfos
}